Skip to content

[CTL] Add support for defaults #1216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

KFilipek
Copy link
Contributor

@KFilipek KFilipek commented Mar 21, 2025

[CTL] Add support for defaults

Description

This PR introduces initial support for setting up default values.

Checklist

  • Code compiles without errors locally
  • All tests pass locally
  • CI workflows execute properly

@KFilipek KFilipek added the enhancement New feature or request label Mar 21, 2025
@KFilipek KFilipek self-assigned this Mar 21, 2025
@KFilipek KFilipek linked an issue Mar 21, 2025 that may be closed by this pull request
@KFilipek KFilipek force-pushed the ctl-default branch 5 times, most recently from 2ec6659 to 408f2c4 Compare March 24, 2025 08:16
@KFilipek KFilipek marked this pull request as ready for review March 24, 2025 09:43
@KFilipek KFilipek requested a review from a team as a code owner March 24, 2025 09:43
umf_os_memory_provider_params_handle_t os_memory_provider_params = NULL;
umf_memory_provider_ops_t *os_provider_ops = umfOsMemoryProviderOps();
if (os_provider_ops == NULL) {
GTEST_SKIP() << "OS memory provider is not supported!";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of adding such skip msg, I guess we should add this test in CMake only when OS prov and disjoint pool are enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's what for we've added a dummy function.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yy? not sure what you mean

@@ -35,7 +35,7 @@ TEST_F(test, ctl_by_handle_os_provider) {

int ipc_enabled = 0xBAD;
ret = umfCtlGet("umf.provider.by_handle.params.ipc_enabled", hProvider,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we have any test for umfCtlGet that pass something else than 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I see it's not a part of this PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're adding a new paramter and without testing values other than 0 it's not properly tested. At least mark in tests a TODO for future.

Copy link
Contributor Author

@KFilipek KFilipek Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This callback discard completely size, so such test will cover completely nothing and will test nothing.

static int CTL_READ_HANDLER(ipc_enabled)(void *ctx,
                                         umf_ctl_query_source_t source,
                                         void *arg, size_t size,
                                         umf_ctl_index_utlist_t *indexes,
                                         const char *extra_name,
                                         umf_ctl_query_type_t query_type) {
    /* suppress unused-parameter errors */
    (void)source, (void)indexes, (void)ctx, (void)extra_name, (void)query_type,
        (void)size;

    int *arg_out = arg;
    os_memory_provider_t *os_provider = (os_memory_provider_t *)ctx;
    *arg_out = os_provider->IPC_enabled;
    return 0;
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm reading your last comment as "size is useless" ;)

Let me re-phrase - whenever size is used, please add a test with various values (user may give some input we may not expect, e.g. on wrong assumptions on how this func works) or mark a TODO for adding tests in the future.

@KFilipek KFilipek force-pushed the ctl-default branch 4 times, most recently from b7324ed to 8e3a2fc Compare March 25, 2025 13:00
Copy link
Contributor

@lplewa lplewa left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

umf_result_t umfCtlExec(const char *name, void *ctx, void *arg); should also have arg size imho.

src/ctl/ctl.c Outdated
@@ -416,11 +402,14 @@ int ctl_query(struct ctl *ctl, void *ctx, umf_ctl_query_source_t source,
errno = EINVAL;
goto out;
}
const char *extra_name = &name[0];
if (strstr(extra_name, "by_handle") != NULL) {
extra_name = &name[0] + name_offset;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please do not include UMF specyfic soultions in ctl* files.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

const char *extra_name,
umf_ctl_query_type_t queryType) {
(void)indexes, (void)source, (void)size, (void)ctx;
assert(queryType == CTL_QUERY_WRITE && "not supported query type");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not an assert. This sould return a correct error code to the user.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • read should work

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed

@@ -99,6 +135,15 @@ static umf_result_t umfPoolCreateInternal(const umf_memory_pool_ops_t *ops,
goto err_pool_init;
}

// Set default property "name" to pool if exists
for (int i = 0; i < UMF_DEFAULT_SIZE; i++) {
if (CTL_DEFAULT_ENTRIES[i][0] != '\0') {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should only call it for entries with matching name, not all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now, should be fine

@@ -0,0 +1,61 @@
/*
* Copyright (C) 2025 Intel Corporation
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho this should not be a .h files

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@KFilipek KFilipek force-pushed the ctl-default branch 2 times, most recently from 338947a to 29380ba Compare March 25, 2025 16:02
@@ -35,7 +35,7 @@ TEST_F(test, ctl_by_handle_os_provider) {

int ipc_enabled = 0xBAD;
ret = umfCtlGet("umf.provider.by_handle.params.ipc_enabled", hProvider,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're adding a new paramter and without testing values other than 0 it's not properly tested. At least mark in tests a TODO for future.

umf_os_memory_provider_params_handle_t os_memory_provider_params = NULL;
umf_memory_provider_ops_t *os_provider_ops = umfOsMemoryProviderOps();
if (os_provider_ops == NULL) {
GTEST_SKIP() << "OS memory provider is not supported!";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yy? not sure what you mean

@KFilipek KFilipek force-pushed the ctl-default branch 4 times, most recently from a8a7fe8 to 56b5408 Compare March 26, 2025 11:57
@KFilipek KFilipek force-pushed the ctl-default branch 11 times, most recently from 312ed18 to db7eca2 Compare April 11, 2025 13:37
@KFilipek KFilipek force-pushed the ctl-default branch 3 times, most recently from f55ddb1 to 141d7bc Compare April 15, 2025 11:54
@KFilipek KFilipek force-pushed the ctl-default branch 9 times, most recently from 33ceeeb to 77692e1 Compare April 17, 2025 09:59
@KFilipek KFilipek requested a review from lplewa April 17, 2025 09:59
@KFilipek KFilipek force-pushed the ctl-default branch 3 times, most recently from 6a2ed97 to 0c02aaa Compare April 17, 2025 19:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CTL - setting global namespace
4 participants